package repository;

import Dto.NewsTbEntity;
import MEx.MExAPI;
import dbConnect.dbConnecter;

import java.sql.ResultSet;
import java.util.Vector;

public class NewsRepository {
    public NewsRepository(){

    }
    public Vector<NewsTbEntity> getNewsTable()
    {
        dbConnecter Con = new dbConnecter();
        Con.getConnection();
        Vector<NewsTbEntity> newsVec = new Vector<NewsTbEntity>();
        try {
            String sql = "select * from news";
            ResultSet re = Con.querySql(sql);

            while (re.next()) {
                NewsTbEntity newsTbEntity = new NewsTbEntity();
                newsTbEntity.setNewsId(re.getInt(1));
                newsTbEntity.setNewsHeadline(re.getString(2));
                newsTbEntity.setNewsName(re.getString(3));
//                newsTbEntity.setNewsContent(re.getString(4));
                newsTbEntity.setUpTime(re.getString(5));
                newsTbEntity.setCheck(re.getString(7));
//                System.out.println(re.getString(4));
                newsVec.add(newsTbEntity);
            }
            return newsVec;
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        finally {
            Con.close();
        }
    }

}
